package com.bifrost.entity;

import java.io.Serializable;
import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;
import java.math.BigInteger;
import java.util.List;


/**
 * The persistent class for the PRODUCT_SERVICE database table.
 */
@Entity
@Table(name = "PRODUCT_SERVICE")
@NamedQuery(name = "ProductService.findAll", query = "SELECT p FROM ProductService p")
public class ProductService implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "SERVICE_ID", unique = true, nullable = false)
    private Long serviceId;

    @Column(name = "IS_ARCHIVED")
    private BigInteger isArchived;

    @Column(name = "SERVICE_DESCRIPTION", length = 255)
    private String serviceDescription;

    @Column(name = "SERVICE_NAME", length = 100)
    private String serviceName;

    @Column(name = "SERVICE_PRICE", precision = 10, scale = 2)
    private BigDecimal servicePrice;
    @Column(name = "SERVICE_TYPE", nullable = false)
    private String serviceType;

    @Column(name = "SORT_ORDER")
    private int sortOrder;

    @Column(name = "UPDATED_BY", length = 64)
    private String updatedBy;

    @Column(name = "CAN_ADD_CART")
    private Boolean canAddCart;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "UPDATED_TIMESTAMP")
    private Date updatedTimestamp;

    //bi-directional many-to-one association to OrderItemService
    @OneToMany(mappedBy = "productService")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<OrderItemService> orderItemServices;

    //bi-directional many-to-one association to MerchantStore
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "MERCHANT_ID" ,foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private MerchantStore merchantStore;

    //bi-directional many-to-one association to SkuAssociation
    @OneToMany(mappedBy = "productService")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<SkuAssociation> skuAssociations;

    //bi-directional many-to-one association to ServicePrice
    @OneToMany(mappedBy = "productService")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<ServicePrice> servicePrices;

    public ProductService() {
    }

    public Long getServiceId() {
        return this.serviceId;
    }

    public void setServiceId(Long serviceId) {
        this.serviceId = serviceId;
    }

    public BigInteger getIsArchived() {
        return this.isArchived;
    }

    public void setIsArchived(BigInteger isArchived) {
        this.isArchived = isArchived;
    }

    public String getServiceDescription() {
        return this.serviceDescription;
    }

    public void setServiceDescription(String serviceDescription) {
        this.serviceDescription = serviceDescription;
    }

    public String getServiceName() {
        return this.serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    public BigDecimal getServicePrice() {
        return this.servicePrice;
    }

    public void setServicePrice(BigDecimal servicePrice) {
        this.servicePrice = servicePrice;
    }

    public int getSortOrder() {
        return this.sortOrder;
    }

    public void setSortOrder(int sortOrder) {
        this.sortOrder = sortOrder;
    }

    public String getServiceType() {
        return serviceType;
    }

    public void setServiceType(String serviceType) {
        this.serviceType = serviceType;
    }

    public String getUpdatedBy() {
        return this.updatedBy;
    }

    public void setUpdatedBy(String updatedBy) {
        this.updatedBy = updatedBy;
    }

    public Date getUpdatedTimestamp() {
        return this.updatedTimestamp;
    }

    public void setUpdatedTimestamp(Date updatedTimestamp) {
        this.updatedTimestamp = updatedTimestamp;
    }

    public List<OrderItemService> getOrderItemServices() {
        return this.orderItemServices;
    }

    public void setOrderItemServices(List<OrderItemService> orderItemServices) {
        this.orderItemServices = orderItemServices;
    }

    public OrderItemService addOrderItemService(OrderItemService orderItemService) {
        getOrderItemServices().add(orderItemService);
        orderItemService.setProductService(this);

        return orderItemService;
    }

    public OrderItemService removeOrderItemService(OrderItemService orderItemService) {
        getOrderItemServices().remove(orderItemService);
        orderItemService.setProductService(null);

        return orderItemService;
    }

    public MerchantStore getMerchantStore() {
        return this.merchantStore;
    }

    public void setMerchantStore(MerchantStore merchantStore) {
        this.merchantStore = merchantStore;
    }

    public List<SkuAssociation> getSkuAssociations() {
        return this.skuAssociations;
    }

    public void setSkuAssociations(List<SkuAssociation> skuAssociations) {
        this.skuAssociations = skuAssociations;
    }

    public SkuAssociation addSkuAssociation(SkuAssociation skuAssociation) {
        getSkuAssociations().add(skuAssociation);
        skuAssociation.setProductService(this);

        return skuAssociation;
    }

    public SkuAssociation removeSkuAssociation(SkuAssociation skuAssociation) {
        getSkuAssociations().remove(skuAssociation);
        skuAssociation.setProductService(null);

        return skuAssociation;
    }

    public List<ServicePrice> getServicePrices() {
        return this.servicePrices;
    }

    public void setServicePrices(List<ServicePrice> servicePrices) {
        this.servicePrices = servicePrices;
    }

    public ServicePrice addSkuServicePrice(ServicePrice servicePrice) {
        getServicePrices().add(servicePrice);
        servicePrice.setProductService(this);

        return servicePrice;
    }

    public ServicePrice removeSkuServicePrice(ServicePrice servicePrice) {
        getServicePrices().remove(servicePrice);
        servicePrice.setProductService(null);

        return servicePrice;
    }

    public Boolean getCanAddCart() {
        return canAddCart;
    }

    public void setCanAddCart(Boolean canAddCart) {
        this.canAddCart = canAddCart;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null) return false;

        ProductService that = (ProductService) o;

        if (!getServiceId().equals(that.getServiceId())) return false;
        if (getServiceDescription() != null ? !getServiceDescription().equals(that.getServiceDescription()) : that.getServiceDescription() != null)
            return false;
        if (!getServiceName().equals(that.getServiceName())) return false;
        return getServicePrice().equals(that.getServicePrice());
    }

    @Override
    public int hashCode() {
        int result = getServiceId().hashCode();
        result = 31 * result + (getServiceDescription() != null ? getServiceDescription().hashCode() : 0);
        result = 31 * result + getServiceName().hashCode();
        result = 31 * result + getServicePrice().hashCode();
        return result;
    }
}